import request from '@/utils/request'

// 获取组织结构树
 export function getOrgTree() {
  
  return request({
    url: '/firstaid-platform/userCenter/dept/selectDeptTree',
    method: 'post'
  })
}

// 获取组织列表
 export function getOrgListByCropId(data) {
  const {parentid} = data;
  if(parentid){
    return request({
        url: '/firstaid-platform/userCenter/dept/selectPage',
        method: 'post',
        data
      })
  }else{
    return getDefaultOrgList();
  }
  
}

// 获取默认组织列表
export function getDefaultOrgList() {
  return request({
    url: '/firstaid-platform/userCenter/dept/selectDeptTree',
    method: 'post'
  })
}

// 创建组织
 export function createOrg(data) {
  return request({
    url: '/firstaid-platform/userCenter/dept/insert',
    method: 'post',
    data
  })
}

// 更新组织
 export function updateOrg(data) {
  return request({
    url: '/firstaid-platform/userCenter/dept/updateById',
    method: 'post',
    data
  })
}

// 删除组织
 export function deleteOrg(data) {
  return request({
    url: '/firstaid-platform/userCenter/dept/deleteById',
    method: 'post',
    data
  })
}

export function syncOrg(){
  return request({
    url  :'/firstaid-platform/userCenter/dept/syncOaOrgInfo',
    method : 'post'
  })
}


export function loadCompany(){
  return request({
    url : '/firstaid-platform/userCenter/dept/selectOrgList',
    method : 'post'
  })
}